<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="案件编号" prop="ajbh">
        <el-input v-model="queryParams.ajbh" placeholder="请输入案件编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="被取保候审人(被行政拘留人)" prop="hsr">
        <el-input v-model="queryParams.hsr" placeholder="请输入被取保候审人(被行政拘留人)" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
      <el-form-item>
      <el-radio-group v-model="queryParams.thshzt">  
      <el-radio label="0" @change="handleQuery">待提交</el-radio>
      <el-radio label="1" @change="handleQuery">已提交</el-radio>
      <el-radio label="3" @change="handleQuery">已退回</el-radio>
      </el-radio-group>
    </el-form-item>
    </el-form>
    <!-- <el-row :gutter="10" class="mb8"> -->
      <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:bzjtable:add']">新增</el-button>
      </el-col>-->
      <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-edit" size="mini" :disabled="!form.xh"
          @click="handleUpdate" >填写退还单据</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-upload" size="mini" :disabled="!form.xh" @click="handleSubmit">提交没收审核</el-button>
      </el-col>
       <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" :disabled="!form.ajmc" @click="handleReturnExport" >打印退还保证金回执</el-button>
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="!form.ajmc" @click="handleDelete" v-hasPermi="['system:bzjtable:remove']">删除</el-button>
      </el-col>-->
      <!-- <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" :disabled="form.xh && !form.xh"
          @click="handleExport" v-hasPermi="['system:bzjtable:export']">打印通知书</el-button>
      </el-col> -->
      <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row> -->

    <el-table v-loading="loading" height="650" :data="bzjtableList" :row-class-name="tableRowClassName"
      @current-change="tableCurrentChange" @row-dblclick="doubleclick">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="序号" align="center" prop="xh" />
      <el-table-column label="没收审核状态" align="center" prop="thshzt" width="120px">
        <template slot-scope="scope">
          <el-tag :type="`${scope.row.thshzt == 0 ? 'primary' : scope.row.thshzt == 1 ? 'success': scope.row.thshzt == 3 ? 'danger' : ''}`">{{ scope.row.thshzt == 0 ?
            `待提交` : scope.row.thshzt == 1 ? `已提交`: scope.row.thshzt == 3 ? `已退回` : ''}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="案件编号" align="center" prop="ajbh" width="200" />
      <el-table-column label="案件名称" align="center" prop="ajmc" width="180"  />
      <el-table-column label="收取法律文书号" align="center" prop="sqwsh" width="150" />
      <el-table-column label="保证金金额" align="center" prop="sqje" width="100" />
      <el-table-column label="退还金额" align="center" prop="thje" />
      <el-table-column label="退还方式" align="center" prop="thfs" />
      <el-table-column label="被取保候审人(被行政拘留人)" align="center" prop="hsr" width="120" />
      <el-table-column label="人员类别" align="center" prop="xjr" width="120" />
      <el-table-column label="性别" align="center" prop="xb" />
      <el-table-column label="出生日期" align="center" prop="csrq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.csrq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="住址" align="center" prop="zz" width="200" /> -->
      <el-table-column label="户籍地址" align="center" prop="hjdz" width="200" />
      <el-table-column label="单位及职务" align="center" prop="dwzw" width="150" />
      <el-table-column label="联系电话" align="center" prop="lxdh" width="150" />
      <el-table-column label="身份证号" align="center" prop="sfzh" width="180" />
      <el-table-column label="委托交款人" align="center" prop="jkr" width="180" />
      <el-table-column label="委托交款人身份证号" align="center" prop="jkrsfz" width="180" />
      <el-table-column label="案件性质" align="center" prop="ajxz"  width="200"/>
      <!-- <el-table-column label="收费方式" align="center" prop="sqfs" /> -->
      <el-table-column label="办案人" align="center" prop="thtfr" width="120" />
      <el-table-column label="办案人联系方式" align="center" prop="thtfrlxfs" width="120" />
      <el-table-column label="退还填发时间" align="center" prop="thtfsj" width="180" />
      <!-- <el-table-column label="批准人" align="center" prop="thtfr" /> -->
      <el-table-column label="取保候审批准时间" align="center" prop="pzsj" width="180" />
      <el-table-column label="办案人" align="center" prop="bar"  width="150"/>
      <el-table-column label="办案人所在单位编号" align="center" prop="dwbh" width="150" />
      <el-table-column label="办案单位" align="center" prop="badw"  width="200"/>
      <!-- <el-table-column label="填报人" align="center" prop="sqtfr" /> -->
      <!-- <el-table-column label="填报时间" align="center" prop="thtfsj" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.thtfsj, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>-->
      <el-table-column label="退还状态" align="center" prop="thzt" />

      <el-table-column label="退还法律文书号" align="center" prop="thwsh" width="150" />
      <!-- <el-table-column label="退还批准人" align="center" prop="thpzr" /> -->
      <!-- <el-table-column label="退还填发时间" align="center" prop="thtfsj" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.thtfsj, '{y}-{m}-{d}') }}</span>
          </template>
      </el-table-column>-->
      <el-table-column label="退还审核状态" align="center" prop="thshzt" width="150" />
      <el-table-column label="退还审核人" align="center" prop="thshr" width="100" />
      <!-- <el-table-column label="退还审核日期" align="center" prop="thshsj" /> -->
      <el-table-column label="退还账户名称" align="center" prop="thxm" width="100" />
      <el-table-column label="退还账号" align="center" prop="thzh" />
      <el-table-column label="退还开户行" align="center" prop="thkhh" width="100" />
      <!-- <el-table-column label="单据状态" align="center" prop="djzt" /> -->
      <!-- <el-table-column label="收取打印状态" align="center" prop="sqdyzt" />
        <el-table-column label="单据时间" align="center" prop="djsj" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.djsj, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="收取开票打印状态" align="center" prop="sqkpzt" />
      <el-table-column label="退还开票打印状态" align="center" prop="thkpzt" />-->
      <el-table-column label="决定日期" align="center" prop="thrq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.thrq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="划拨法律文书号" align="center" prop="hbwsh" />
        <el-table-column label="划拨单位名称" align="center" prop="hbdw" />
        <el-table-column label="划拨金额" align="center" prop="hbje" />
        <el-table-column label="划拨操作员" align="center" prop="hbry" />
        <el-table-column label="划拨日期" align="center" prop="hbrq" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.hbrq, '{y}-{m}-{d}') }}</span>
          </template>
      </el-table-column>
      <el-table-column label="划拨单位联系人电话" align="center" prop="hblxdh" />-->
      <!-- <el-table-column label="划拨时间" align="center" prop="hbsj" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.hbsj, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
      <el-table-column label="划拨时间" align="center" prop="hbczy" />-->
      <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:bzjtable:edit']">修改</el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:bzjtable:remove']">删除</el-button>
          </template>
      </el-table-column>-->
      <!-- <el-table-column fixed="right" label="操作"  align="center"  width="220" >
        <template slot-scope="scope">
          <el-row :gutter="10" class="mb8">
              <el-button type="warning" plain size="mini" @click="handleckfj(scope.row)" >查看附件</el-button>
              <el-button type="primary" plain size="mini" @click="handlecklc(scope.row)" >查看流程</el-button>
          </el-row>
        </template>
      </el-table-column> -->
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="tit" :visible.sync="open" width="60%">
      <el-form ref="forms" :inline="true" :model="form" :rules="ruless" label-width="auto" :hide-required-asterisk="true"  class="creation demo-form-inline">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-divider content-position="center">案件信息</el-divider>
          </el-col>
        <el-col :span="12" >
        <el-form-item label="案件编号">
          <el-input v-model="form.ajbh" placeholder="请输入案件编号" disabled/>
        </el-form-item>
      </el-col>
        <el-col :span="12" >
        <el-form-item label="案件名称">
          <el-input v-model="form.ajmc" placeholder="请输入案件名称" disabled />
        </el-form-item>
      </el-col>
      <!-- <el-col :span="24">
          <el-divider content-position="center">个人信息</el-divider>
        </el-col> -->
        <el-col :span="12" >
        <el-form-item label="被取保候审人(被行政拘留人)">
          <el-input v-model="form.hsr" placeholder="请输入被取保候审人(被行政拘留人)" disabled/>
        </el-form-item>
      </el-col>
      <el-col :span="12" >
        <el-form-item label="人员类别">
          <el-input v-model="form.xjr" placeholder="请输入人员类别" :disabled="true" style="width: 100%"/>
        </el-form-item>
        </el-col>
        <el-col :span="12" >
        <el-form-item label="联系电话">
            <el-input v-model="form.lxdh" placeholder="请输入联系电话" :disabled="true" style="width: 100%"/>
        </el-form-item>
        </el-col>
        <el-col :span="12" >
        <el-form-item label="委托人">
          <el-input v-model="form.jkr" placeholder="请输入委托人" disabled/>
        </el-form-item>
      </el-col>
        <el-col :span="12" >
        <el-form-item label="委托人身份证号">
          <el-input v-model="form.jkrsfz" placeholder="请输入委托人身份证号" disabled/>
        </el-form-item>
      </el-col>
      <el-col :span="24">
          <el-divider content-position="center">退还信息</el-divider>
        </el-col>
      <el-col :span="12" >
        <el-form-item label="办案人" prop="thtfr">
          <el-input v-model="form.thtfr" placeholder="请输入办案人" />
        </el-form-item>
      </el-col>
      <el-col :span="12" >
        <el-form-item label="办案人联系方式" >
          <el-input v-model="form.thtfrlxfs" placeholder="请输入办案人" />
        </el-form-item>
      </el-col>
        <el-col :span="12" >
        <el-form-item label="退还决定文书号" prop="thwsh">
          <el-input v-model="form.thwsh" placeholder="请输入退还决定文书号" />
        </el-form-item>
      </el-col>
      <!-- <el-col :span="12" >
        <el-form-item label="缴纳人" prop="thxm">
          <el-input v-model="form.thxm" placeholder="请输入缴纳人" />
        </el-form-item>
      </el-col> -->
      <el-col :span="12" >
        <el-form-item label="被取保候审人(被行政拘留人)">
          <el-input v-model="form.hsr" placeholder="请输入被取保候审人(被行政拘留人)"/>
        </el-form-item>
      </el-col>
        <el-col :span="12" >
        <el-form-item label="退还金额" prop="thje">
          <el-input v-model="form.thje" placeholder="请输入退还金额" />
        </el-form-item>
      </el-col>
        <el-col :span="12" >
        <el-form-item label="退还方式" prop="thfs">
          <el-select v-model="form.thfs" placeholder="请选择退还方式">
            <el-option v-for="item in [{ id: 1, name: '指定账户' }, { id: 2, name: '原路返回' }]"
              :key="item.id" :label="item.name" :value="item.name"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12" >
        <el-form-item label="退还账户名称" prop="thxm" v-if="form.thfs === '指定账户'">
          <el-input v-model="form.thxm" placeholder="请输入退还账户名称" />
        </el-form-item>
      </el-col>
        <el-col :span="12" v-if="form.thfs === '指定账户'">
        <el-form-item label="退还开户行" prop="thkhh">
          <el-input v-model="form.thkhh" placeholder="请输入退还开户行" />
        </el-form-item>
      </el-col>
        <el-col :span="12" v-if="form.thfs === '指定账户'">
        <el-form-item label="退还账号" prop="thzh">
          <el-input v-model="form.thzh" placeholder="请输入退还账号" />
        </el-form-item>
      </el-col>
        <el-col :span="12" >
        <el-form-item label="决定日期" prop="thrq">
          <el-date-picker clearable v-model="form.thrq" type="date" value-format="yyyy-MM-dd"
            placeholder="请选择退还日期"></el-date-picker>
        </el-form-item>
      </el-col>
        <el-col :span="12" >
        <el-form-item label="退还填发时间" prop="thtfsj">
          <el-date-picker clearable v-model="form.thtfsj" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
          :disabled="true" placeholder  ="请选择退还填发时间"></el-date-picker>
        </el-form-item>
      </el-col>
      <el-col :span="12" >
        <el-form-item label="附件选择" prop="files">
          <Upload style="width: 250px;" v-model="form.files" :data="{}" 
             multiple></Upload>
        </el-form-item>
      </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="open=false">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="查看附件" :visible.sync="dialogFormVisible">
      <el-table height="600" border :data="fileList" :header-cell-style="{ backgroundColor: 'rgb(237 237 237)'}">
        <el-table-column label="文件名称" prop="fjmc" />
        <el-table-column label="环节" prop="lb" />
        <el-table-column label="文件类型" prop="typeName" />
        <el-table-column fixed="right" label="操作" width="200">
          <template slot-scope="scope">
            <el-button type="success" plain size="mini" @click="handlexzfj(scope.row)" :disabled="!scope.row.wjdz" >下载附件</el-button>
            <el-button type="success" plain size="mini" @click="yul(scope.row)" :disabled="!(scope.row.wjdz.split('.')[1] == 'png' || scope.row.wjdz.split('.')[1] == 'jpg' || scope.row.wjdz.split('.')[1] == 'jpeg')" >预览</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog :visible.sync="pdfs" width="45%">
         <div style="display: flex;align-items: center;justify-content: center;">
          <img :src="this.pdfUrl" alt width="80%" />
         </div>
    </el-dialog>
    <el-dialog title="查看流程" :visible.sync="dialogFlowerTable"  @closed="dialogFlowerTable=false">
      <el-table height="600" border :data="flowerList" :header-cell-style="{ backgroundColor: 'rgb(237 237 237)'}">
        <el-table-column label="案件类别" prop="lb" hidden/>
        <el-table-column label="审批环节" prop="ajlx" />
        <el-table-column label="审批意见" prop="spyj" width="200"/>
        <el-table-column label="审批人" prop="spr" />
        <el-table-column label="审批人职务" prop="sprzw" />
        <el-table-column label="审批单位" prop="spdw" width="200"/>
        <el-table-column label="审批时间" prop="spsj" width="180"/>
      </el-table>
    </el-dialog>
    <div ref="print" class="box" v-show="isShow">
      <div class="lf">
        <div class="heade">
          <h4>哈尔滨市公安局</h4>
          <h2>收取保证金通知书</h2>
          <p>(存根)</p>
        </div>
        <div class="cont">
          <el-form :model="form" label-width="90px">
            <el-form-item label="案件名称">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.ajmc }}</p>
            </el-form-item>
            <el-form-item label="案件编号">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.ajbh }}</p>
            </el-form-item>
            <el-form-item label="取保候审人">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.hsr }}</p>
            </el-form-item>
            <el-form-item label="出生日期">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.csrq }}</p>
            </el-form-item>
            <el-form-item label="地址">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.zz }}</p>
            </el-form-item>
            <el-form-item label="单位及职业">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.dwzw }}</p>
            </el-form-item>
            <el-form-item label="保证金数额">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.sqje }}</p>
            </el-form-item>
            <!-- <el-form-item label="代收银行" >
                <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.ajmc }}</p>
            </el-form-item>-->
            <el-form-item label="收取时间">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.sqrq }}</p>
            </el-form-item>
            <el-form-item label="退还填报人">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.thtfr }}</p>
            </el-form-item>
            <!-- <el-form-item label="批准时间" >
                <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.ajmc }}</p>
            </el-form-item>-->
            <el-form-item label="办案人">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.bar }}</p>
            </el-form-item>
            <el-form-item label="办案单位">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.badw }}</p>
            </el-form-item>
            <el-form-item label="退还填发时间">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.thtfsj }}</p>
            </el-form-item>
            <el-form-item label="填发人">
              <p style="border-bottom: 1px solid #dcdfe6">{{ this.form.sqtfr }}</p>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div class="lr">
        <div class="heade">
          <h4>哈尔滨市公安局</h4>
          <h2>收取保证金通知书</h2>
        </div>
        <div class="cont">
          <div class="line">{{ this.form.ajbh }}：</div>
          <p class="text">
            根据《中华人民共和国刑事诉讼法》第六十八条、
            第七十二条之规定，请持此通知书于{{ this.form.jnsj }}
            日之前到银行交纳取保候审保证金（大写）{{ this.form.sqje }}元
          </p>
          <div class="footer">
            <p>哈尔滨市公安局</p>
            <p>{{parseTime(this.form.sqtfsj, '{y}-{m}-{d}') }}</p>
          </div>
        </div>
      </div>
    </div>
    <div ref="print1" class="bb" v-show="isReturnShow">
      <div class="box1">
      <div class="box2">
        <div class="heade">
          <h2>{{this.$store.state.user.deptName}}</h2>
          <h1 style="white-space: pre;">退 还 保 证 金 通 知 书</h1>
          <!-- <span>（回&nbsp;&nbsp;&nbsp;执）</span> -->
          <span style="margin-bottom: 50px;font-weight: 500;font-size: 20px;white-space: pre;">（回  执）</span>

          <p style="margin-top: 50px;margin-left: 200px;font-size: 20px;">{{ this.form.thwsh }}</p>
        </div>
        <div class="cont">
          <div class="line">{{this.$store.state.user.deptName}}：</div>
          <p class="contu">
            根据你局通知，我行已退还
            <span>{{ this.form.hsr }}</span> (性别
            <span>{{ this.form.xb }}</span> ，出生日期
            <span>{{ this.form.csrq }}</span>
            住址
            <span>{{ this.form.hjdz }})</span>
            交纳的取保候审保证金（大写）
            <span>{{handleReturnBigNum(this.form.thje)}}</span>。
          </p>
          <div class="footer">
            <p>{{ this.form.dsyhbh }}</p>
            <p style="margin:10px 0 0 10px">{{parseTime(this.form.thtfsj, '{y}年{m}月{d}日') }}</p>
            <img src="@/assets/images/gz.png" width="150" class="imgs" alt />
          </div>
        </div>
        </div>
      </div>
    </div>
    <el-dialog title="提交意见" :visible.sync="dialogSuggest" @close="dialogSuggest=false">
      <div style="display: flex;align-items: stretch;justify-content: space-evenly;flex-direction: column;height: 220px;">
      <div style="display: flex;align-items: center;justify-content: center;">
        <div>提交意见:</div>
        <el-input v-model="spyj" style="width: 85%;" :rows="5" type="textarea"></el-input>
      </div>
      <div style="display: flex;align-items: center;justify-content: center;">
        <div style="margin-left: 11px;">提交人:</div>
        <el-input v-model="spr" style="width: 40%;" type="text"></el-input>
        <div style="margin-left: 11px;">职务:</div>
          <el-select v-model="sprzw" style="width: 40%;" :rows="5" type="text"  clearable  placeholder="请选择职务">
            <el-option
          v-for="item in dict.type.sys_sprzw"
          :key="item.value"
          :label="item.label"
          :value="item.label"
        />
            </el-select>
      </div>
    </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormSuggest">确 定</el-button>
        <el-button @click="dialogSuggest=false">取 消</el-button>
      </div>
    </el-dialog>

<!-- 双击页面 -->
<el-dialog :title="tit" :visible.sync="doubleopen" width="80%" @closed="gb">
  <el-form ref="form" :inline="true" :model="form" :rules="ruless" label-width="auto" :hide-required-asterisk="true"  class="creation demo-form-inline">
          <el-row :gutter="20">
            <el-col :span="24">
            <el-divider content-position="center">案件信息</el-divider>
          </el-col>
          <el-col :span="8">
          <el-form-item label="案件编号" prop="ajbh">
            <el-input v-model="form.ajbh" :disabled="true"/>
          </el-form-item>
          </el-col>
          <el-col :span="8">
          <el-form-item label="案件名称" prop="ajmc">
            <el-input v-model="form.ajmc"  :disabled="true"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="案件性质" prop="ajxz">
            <el-input v-model="form.ajxz" :disabled="true"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="收取法律文书号" prop="sqwsh">
            <el-input v-model="form.sqwsh"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="办案人" prop="bar">
            <el-input v-model="form.bar"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="办案单位" prop="badw">
            <el-input v-model="form.badw"  :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="被取保候审(被行政拘留)人" prop="hsr">
            <el-input v-model="form.hsr"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="人员类别" prop="xjr">
            <el-input v-model="form.xjr"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="性别" prop="xb">
            <el-input v-model="form.xb"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="身份证号" prop="sfzh">
            <el-input v-model="form.sfzh"  :disabled="true"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="户籍地址" prop="hjdz">
            <el-input v-model="form.hjdz"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="出生日期" prop="csrq">
            <el-date-picker clearable
              v-model="form.csrq"
              type="date"
              value-format="yyyy-MM-dd"
              style="width: 100%;"
              :disabled="true">
            </el-date-picker>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="联系电话" >
            <el-input v-model="form.lxdh"  :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="委托人" >
            <el-input v-model="form.jkr"  :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="委托人身份证号">
            <el-input v-model="form.jkrsfz"  :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-divider content-position="center">退还信息</el-divider>
          </el-col>
          <el-col :span="8">
          <el-form-item label="保证金金额" prop="sqje">
            <el-input v-model="form.sqje"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="退还金额" prop="thje">
            <el-input v-model="form.thje"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="退还方式" prop="thfs">
            <el-input v-model="form.thfs"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="办案人" prop="thtfr">
            <el-input v-model="form.thtfr"  :disabled="true" />
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="退还填报时间" prop="thtfsj">
            <el-input v-model="form.thtfsj"  :disabled="true" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"/>
          </el-form-item>
        </el-col>

          </el-row>
        </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain icon="el-icon-edit"  :disabled="!form.xh" @click="handleUpdate">填写退还单据</el-button>
        <el-button type="success" plain icon="el-icon-upload"  :disabled="!form.xh" @click="handleSubmit">提交退还审核</el-button>
        <el-button type="warning" plain icon="el-icon-download" :disabled="!form.ajmc" @click="handleReturnExport" >打印退还保证金回执</el-button>
        <el-button type="warning" @click="handleckfj(form)" >查看附件</el-button>
        <el-button type="primary" @click="handlecklc(form)" >查看流程</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>
  
<script>
import { backToPersonList,  delBzjtable, addBzjtable, downLoadFile, updateThshzt, addAjxzTree,thsh,getFjList,getListByXhDetail ,getBackToPerson} from "@/api/system/bzjtable";
import selectMultiple from '@/views/collect/addSecurity/selectMultiple'
import Print from '@/utils/print.js'
import Upload from './Upload'
import { convertCurrency } from '@/utils/index'
import { blobValidate } from "@/utils/ruoyi";


export default {
  name: "Bzjtable",
  dicts: ['sys_type','sys_sprzw'],
  data() {
    let amount = (rule, value, callback) => {
      if (value) {
        if (!/^(0|[1-9]\d*)(\s|$|\.\d{1,2}\b)/.test(value)) return callback(new Error('请输入非负数、最多含两位小数'))
        if (value <= 0) return callback(new Error('退还金额应大于0'))
        if (value > 999999999999.99) return callback(new Error('退还金额不能超过999999999999.99'))
      } else {
        return callback(new Error('请输入退还金额'))
      }
      callback()
    }
    let dialogVisible = (rule, val, callback) => {
      if (!val) callback(new Error('请输入手机号'))
      let exp = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/)
      if (!exp.test(val)) {
        return callback(new Error('手机号格式不对'))
      }
      return callback()
    }
    let dialogVisible1 = (rule, val, callback) => {
      if (!val) callback(new Error('请输入身份证号'))
      let exp = new RegExp(/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/)
      if (!exp.test(val)) {
        return callback(new Error('身份证号格式不对'))
      }
      return callback()
    }
    let dialogVisibleFile = (rule, value, callback) => {
      console.log(value?.length, ';');
      if (rule.required) {
        if (value?.length) {
          callback()
        } else {
          return callback(new Error('请选择文件'))
        }
      }
      callback()
    }
    return {
      dialogFlowerTable:false,
      spyj:'',
      spr:'',
      sprzw:'',
      isReturnShow:false,
      dialogFormVisible:false,
      dialogSuggest:false,
      doubleopen:false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      fileList: [],
      directoryList: [],
      fileTableList: [],
      pdfs: false,
      flowerList:[],  
      pdfUrl: '',
      directoryList: [],
      isShow: false,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      bzjtableList: [],
      // 弹出层标题
      tit: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ajbh : null,
        hsr: null,
        thshzt:'0'
      },
      // formInfo: {},
      // 表单参数
      form: {
        lxdh: '',
        sfzh: '',
        flwsh:null,
        thtfsj: this.getNowFormatDate()
      },
      currentIndex: '',
      // 表单校验
      ruless: {
        thwsh: [{ required: true,message:"请填写法律文书号", trigger: 'change' }],
        thfs: [{ required: true,message:"请选择退还方式", trigger: 'change' }],
        thtfr: [{ required: true,message:"请填写办案人", trigger: 'change' }],
        thtfrlxfs: [{ required: true, validator: dialogVisible, trigger: 'change' }],
        thzh: [{ required: true,message:"请填写退还账户", trigger: 'change' }],
        thrq: [{ required: true,message:"请填写退还决定日期", trigger: 'change' }],
        thxm: [{ required: true,message:"请填写退还账户名称", trigger: 'change' }],
        thje: [{ required: true, validator: amount, trigger: 'change' }],
        lxdh: [{ required: true, validator: dialogVisible, trigger: 'change' }],
        sfzh: [{ required: true, validator: dialogVisible1, trigger: 'change' }],
        files: [{ required: true, validator: dialogVisibleFile, trigger: 'change' }],
        // thje: [{ required: true,message:"请填写金额", trigger: 'change' }]

      }
    };
  },
  components: {
    selectMultiple,
    Upload
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      backToPersonList(this.queryParams).then(response => {
        response.rows.forEach((item, index) => {
          item.pIndex = index + 1
        })
        this.bzjtableList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
      addAjxzTree({}).then((res) => {
        this.directoryList = res.map(item => {
          item.level = 1
          item.name = item.label
          item.value = item.id
          item.children && item.children.forEach((i) => {
            i.level = 2
            i.name = i.label
            i.value = i.id
            if (i.children && i.children.length) {
              i.children.forEach((k) => {
                k.level = 3
                k.name = k.label
                k.value = k.id
              })
            }
          })
          // this.recursionFun(item)
          return item
        })
      })
    },
    submitFormSuggest() {
      if(!this.spyj){
        return this.$message.error('请输入意见')
      }
      if(!this.spr){
        return this.$message.error('请输入提交人')
      }      
      if(!this.sprzw){
        return this.$message.error('请选择提交人职务')
      }
      if (this.form.xh != null) {
        this.form.thshzt = 1
        this.form.thzt = 0
        this.form.spyj = this.spyj
        this.form.spr = this.spr
        this.form.sprzw = this.sprzw
        thsh(this.form).then(response => {
          this.$modal.msgSuccess("提交成功");
          this.dialogSuggest =false
          this.doubleopen =false
          this.getList();
        });
      }
    },
    handleSubmit(){
      // if (this.form.xh != null) {
      //   this.form.thshzt = 1
      //   this.form.thzt = 0
      //   thsh(this.form).then(response => {
      //     this.$modal.msgSuccess("提交成功");
      //     this.getList();
      //   });
      // }
      this.dialogSuggest =true
    },

    // recursionFun(item) {
    //   if (item.children) {
    //     item.children.map(it => {
    //       it.name = it.label
    //       it.value = it.id
    //       this.recursionFun(it)
    //       return it
    //     })
    //   } else {
    //     return
    //   }
    // },
    // 取消按钮
    cancel() {
      this.open = false;
      this.doubleopen = false;
      this.getList();
      this.reset();
    },
      /**双击操作 */
      doubleclick(row,event){
      this.form = row;
      this.doubleopen = true;
    },
    gb() {
      this.getList();
    },
    selectVal(val) {
      this.form.ajxz = val
      // this.catalogId = val?this.$refs.selectMultiple.selectTree:'';
      // let codePrefix = this.$refs.selectMultiple.selectData.codePrefix || this.formData.codePrefix;
      // if(!this.formData.code.startsWith(codePrefix)){
      //   this.getCode(this.$refs.selectMultiple.selectData.codePrefix)
      // }
      // if(this.formData.name){
      //   this.$refs.form.validateField('name');
      // }
    },
    // 表单重置
    reset() {
      this.form = {
        xh: null,
        ajbh: null,
        ajmc: null,
        sqwsh: null,
        hsr: null,
        xjr: null,
        xb: null,
        csrq: null,
        zz: null,
        hjdz: null,
        dwzw: null,
        lxdh: null,
        sfzh: null,
        ajxz: null,
        sqje: null,
        sqfs: null,
        sqzt: null,
        jkr: null,
        jkrsfz: null,
        dsyhbh: null,
        jnsj: null,
        jnkh: null,
        thtfr: null,
        pzsj: null,
        bar: null,
        dwbh: null,
        badw: null,
        sqrq: null,
        thtfsj: this.getNowFormatDate(),
        msje: null,
        mszt: null,
        msyy: null,
        mswsh: null,
        mspzr: null,
        mspzsj: null,
        mstfr: null,
        msrq: null,
        mstfsj: null,
        msshzt: null,
        mskhzt: null,
        mskhsj: null,
        mskhczr: null,
        thje: null,
        thfs: null,
        thzt: null,
        thrq: null,
        thwsh: null,
        thpzr: null,
        thshzt: null,
        thshr: null,
        thshsj: null,
        thxm: null,
        thzh: null,
        thkhh: null,
        djzt: null,
        sqdyzt: null,
        djsj: null,
        sqkpzt: null,
        thkpzt: null,
        hbwsh: null,
        hbdw: null,
        hbje: null,
        hbry: null,
        hbrq: null,
        hblxdh: null,
        hbsj: null,
        hbczy: null
      };
      this.resetForm("forms");
    },
    tableRowClassName({ row, column, rowIndex, columnIndex }) {
      //逻辑判断决定是否修改样式，如果分组一致则使用同一个样式
      return row.pIndex == this.currentIndex ? 'hover-bg' : ''
    },
    tableCurrentChange(row) {
      // getBackToPerson
      getBackToPerson(row.xh).then((res) => {
        this.form = res.data
        this.form.files.forEach((item) => {
          item.newFileName = item.fjmc
          item.fileType = item.wjlx
        })
      })
      this.currentIndex = row?.pIndex
    },
    yul(val) {
      downLoadFile({ wjdz: val.wjdz }).then(async (data) => {
          // if (this.wjdz && this.wjdz.split('.')[1] == 'png' || this.wjdz &&this.wjdz.split('.')[1] == 'jpg' || this.wjdz.split('.')[1] == 'jpeg') {
          const url = window.URL.createObjectURL(data);
          this.pdfUrl = url;//直接用iframe标签
          this.pdfs = true
          // }
        })
    },
    handleckfj(row) {
        this.dialogFormVisible = true
        getFjList({ xh: row.xh }).then((res) => {
            this.fileList = res.rows
        })

    },
    handlexzfj(val) {
      // this.download('/confiscate/forfeitureOfDeposit/downLoadFile', { wjdz: this.form.wjdz }, `role_${new Date().getTime()}.png`)
      downLoadFile({ wjdz: val.wjdz }).then(async (data) => {
          this.$modal.msgSuccess("下载成功");
          const url = window.URL.createObjectURL(data);
          this.pdfUrl = url;//直接用iframe标签
          const isBlob = blobValidate(data);
          if (this.wjdz && this.wjdz.split('.')[1] == 'png' || this.wjdz && this.wjdz.split('.')[1] == 'jpg' || this.wjdz && this.wjdz.split('.')[1] == 'jpeg') {
              if (isBlob) {
                  const blob = new Blob([data])
                  saveAs(blob, `role_${new Date().getTime()}.png`)
              } else {
                  const resText = await data.text();
                  const rspObj = JSON.parse(resText);
                  const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
                  Message.error(errMsg);
              }
          } else if (this.wjdz && this.wjdz.split('.')[1] == 'pdf') {
              // let pdfUrl = window.URL.createObjectURL(new Blob([data], { type: "application/pdf" }));
              // window.open(pdfUrl)
              let blob = new Blob([data], { type: 'application/pdf' });
              let downloadElement = document.createElement("a");
              let href = window.URL.createObjectURL(blob); //创建下载的链接
              downloadElement.href = href;
              downloadElement.download = `pdf下载`    //下载后的文件名，根据需求定义
              document.body.appendChild(downloadElement);
              downloadElement.click(); //点击下载
              document.body.removeChild(downloadElement); //下载完成移除元素
              window.URL.revokeObjectURL(href); //释放掉blob对象
          } else {
              const blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) // response就是接口返回的文件流
              const objectUrl = URL.createObjectURL(blob)
              const a = document.createElement('a') // 创建a标签
              a.href = objectUrl
              a.download = 'excel下载' // 自定义文件名
              a.click() // 下载文件
              window.URL.revokeObjectURL(objectUrl) // 释放内存
              // link.remove()
          }
          this.dialogFormVisible = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.hsr = ''
      this.queryParams.ajbh = ''
      this.queryParams.thshzt = '0'
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //查看附加
    handleckfj(row) {
      this.dialogFormVisible = true
      debugger;
      getFjList({ xh: row.xh }).then((res) => {
        this.fileList = res.rows
        this.fileList.forEach((item) => {
          item.typeName = this.dict.type.sys_type.filter((e) => item.wjlx == e.value)[0].label
        })
      })
    },
    handlecklc(row) {
      console.log("row",row);
      this.dialogFlowerTable = true
      getListByXhDetail(row.xh,0).then((res) => {
        this.flowerList = res.rows
      })
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.tit = "添加";
      // this.$nextTick(() => {
      //   this.$refs.selectMultiple.value = null;
      // })
      this.reset();
      this.open = true;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.tit = "保证金退还";
      // this.$nextTick(() => {
      //   this.$refs.selectMultiple.value = this.form.ajxz;
      // })
      this.form.mstfsj = this.getNowFormatDate()
      this.form.thtfsj = this.getNowFormatDate()
      this.form.thje = this.form.sqje
      // this.form.thtfr = this.form.bar
      if (this.form.msje) {
        this.form.thje = this.form.sqje - this.form.msje
      }
      this.open = true;
      // this.reset();
      // const XH = row.XH || this.ids
      // getBzjtable(XH).then(response => {
      //   this.form = response.data;
      //   this.open = true;
      // });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs.forms.validate(valid => {
        if (valid) {
          let flag =true
          this.form.files.forEach((item) => {
            if (!item.fileType) {
              flag = false
              this.$modal.msgError("请选择附件类型");
              return 
            }
          })
          if (flag) {
            if (this.form.xh != null) {
              this.form.files.forEach((item)=>{
                item.wjlx = item.fileType
              })
              console.log(this.form.thtfr)
            updateThshzt(this.form).then(response => {
              this.$modal.msgSuccess("退还信息保存成功");
              this.open = false;
              this.doubleopen = false;
              this.getList();
              this.reset();
            });
          } else {
            this.form.sqzt = 0
            addBzjtable(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.doubleopen = false;
              this.getList();
              this.reset();
            });
            }
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      // const XHs = row.XH || this.ids;
      // this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + this.form.xh + '"的数据项？').then(function () {
      //   return delBzjtable(this.form.xh);
      // }).then(() => {
      //   this.getList();
      //   this.$modal.msgSuccess("删除成功");
      // }).catch(() => { });

      this.$confirm('是否确认删除【请填写功能名称】编号为"' + this.form.xh + '"的数据项？', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delBzjtable(this.form.xh).then(res => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.isShow = true
      console.log(this.$refs.print);
      this.$nextTick(() => {
        Print(this.$refs.print)
        this.isShow = false
      })
      // this.download('system/bzjtable/export', {...this.queryParams}, `bzjtable_${new Date().getTime()}.xlsx`)
    },
    handleReturnExport() {
      this.isReturnShow = true
      console.log(this.$refs.print1);
      this.$nextTick(() => {
        Print(this.$refs.print1)
        this.isReturnShow = false
      })
    },
    handleReturnBigNum(data) {
      return convertCurrency(data)
    }
  }
};
</script>
<style rel="stylesheet/scss" lang="scss">
@page {
  size: 1220px 880px;
  margin-top: 0mm;
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
.creation {
  .el-form-item {
    margin-bottom: 15px;
  }
  .el-textarea {
    width: 250px;

  }
  ::v-deep.el-input__inner {
    width: 250px;
  }

  .xx {
    ::v-deep.el-input__inner {
      width: 630px;
    }
  }
}

::v-deep .el-table__body-wrapper::-webkit-srollbar-track {
  background-color: rgba(255, 255, 255, 0);
}

//可设置胶囊宽高
::v-deep .el-table__body-wrapper::-webkit-scrollbar {
  height: 12px;
  width: 10px;
  opacity: 0.5;
}

// 设置胶囊色
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
  border-radius: 15px;
  background-color: #cdd9e6;
}

.box {
  display: flex;
  justify-content: center;
  padding: 40px;
  height: 800px;

  .heade {
    text-align: center;

    >h4 {
      font-weight: 600;
    }

    >h2 {
      margin: 6px 0 5px 0;
      font-weight: 600;
    }
  }

  .cont {
    margin-top: 30px;

    .line {
      width: 150px;
      height: 20px;
      text-align: right;
      margin-left: 30px;
      border-bottom: 1px solid #000;
    }

    .text {
      text-indent: 24px;
      width: 400px;
      line-height: 40px;
      // margin-top: 50px;
      margin: 20px auto;
    }

    .footer {
      width: 400px;
      margin-top: 50px;
      float: right;
      text-align: center;
    }
  }

  .lf {
    width: 300px;
    border: 1px solid #000;
    margin-right: 50px;
    padding: 6px;
  }

  .lr {
    width: 600px;
    padding: 6px;
    border: 1px solid #000;
  }

  ::v-deep.el-form-item {
    margin-bottom: 0;
  }

  // .noBorder {

  //   ::v-deep.el-input__inner:focus {
  //     box-shadow: 0 0 0 0 !important;
  //   }

  //   ::v-deep.el-input__inner {
  //     border-radius: 0 !important;
  //     border: none !important;
  //     border-bottom: 1px solid #dcdfe6 !important;
  //   }
  // }
}

::v-deep .el-table__body .el-table__row.hover-bg td {
  background-color: #cde6f7 !important;
}
.bb {
  padding-top: 40px;

  .box1 {
    position: relative;

    margin: 0 auto;
    // padding: 40px;
    width: 550px;
    height: 700px;
    border: 3px solid #000;
    .box2{
      position: absolute;
  // margin: 0 auto;
  margin: 3px;
    padding: 20px;
    width: 538px;
    height: 688px;
    border: 1px solid #000;

    .heade {
      text-align: center;
margin-top:20px ;
      >h2 {
              margin-top:40px ;
// font-family: monospace;
        // font-weight: 800;
      }

      >h1 {
        // margin-top:20px ;
        margin: 20px 0 20px 0;
        font-weight: 600;
      }
    }

    .cont {
      position: relative;
      margin-top: 50px;
      font-size: 18px;

      .line {
        width: 180px;
        height: 23px;
        text-align: right;
        // margin-left: 30px;
        border-bottom: 1px solid #000;
        font-size: 20px;
      }

      .contu {
        text-indent: 24px;
        line-height: 45px;
        width: 500px;
        font-size: 20px;
        margin: 20px auto;

        >span {
          border-bottom: 1px solid #000;
        }
      }

      .footer {
        position: absolute;
        bottom: -150px;
        right: 30px;
        width: 220px;
        text-align: center;

        .imgs {
          border-radius: 50%;
          position: absolute;
          top: -30px;
          right: 15px;
        }
      }
    }
  }
}
}
::v-deep .demo-form-inline .el-input {
  --el-input-width: 220px !important;
}
</style>